1 using System.Collections;
2 using
System.Collections.Generic;
3 using
UnityEngine;
4
5 public
class PlayerBullet : MonoBehaviour {
6
7     
public int damage;
8     
public GameObject hit;
9
10     
// Use this for initialization
11     
void Start () {
12         
13     }
14     
15     
// Update is called once per frame
16     
void Update () {
17         
18     }
19
20     
void OnTriggerEnter2D(Collider2D collider){
21         
if(collider.CompareTag("Enemy")){
22             Instantiate (hit, transform.position, Quaternion.identity);
23             collider.transform.GetComponent<EnemyHealth> ().Health (damage);
24             Destroy (gameObject);
25         }
26
27         
if(collider.CompareTag("Boss")){
28             Instantiate (hit, transform.position, Quaternion.identity);
29             collider.transform.GetComponent<BossHealth> ().Health (damage);
30             Destroy (gameObject);
31         }
32     }
33 }


Use this for initialization

Update is called once per frame



Gõ tìm kiếm nhanh...